<?php
/**
 * @auther:周卫星
 * @date:2019/11/1
 * @fileName:index.blade.php
 * @fileDesc: 菜单的首页
 */
?>

@extends('biz.layout.biz_layout')
@section('title', '菜品管理-菜品列表')
@push('css')
    <style>
        .table_list{height: 100px; border: 1px solid #ddd; text-align: center; margin-left: 10px;margin-bottom: 10px;line-height: 100px;cursor: pointer;display: inline-block;border-radius: 4px;box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.4);}
        .table-grid-title {
            height: 120px;
            width: 120px;
            line-height: 120px;
            text-align: center;
        }
    </style>
    <style>
        @media screen and (max-width: 450px) {
            .layui-form-item .layui-input-inline {
                display: block;
                float: none;
                left: -3px;
                width: auto;
                margin: 0 0 10px 0;
            !important
            }
        }
    </style>
    <link rel="stylesheet" href="{{ Illuminate\Support\Facades\URL::asset('css/biz/table/index.css') }}">
@endpush

@push('js')
    <script src="{{ Illuminate\Support\Facades\URL::asset('js/biz/goods/index.js') }}"></script>
@endpush

@section('content')
    <div class="layui-btn-container">
        <button class="layui-btn" id="addBtn">添加菜品</button>
    </div>
    <div class="layui-tab" lay-filter="goods">
        <ul class="layui-tab-title">
            <li class="layui-this">正常</li>
            <li>下架</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form" action="">
                    <div class="layui-form-item layui-row">
                        <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs3 layui-col-sm3">
                            <input type="text" name="goods_name" placeholder="请输入菜品" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs3 layui-col-sm3 layui-row">
                            <select name="sgc_id">
                                <option value=""></option>
                                @foreach($class_list as $key => $value)
                                <option value="{{ $value['sgc_id'] }}">{{ $value['sgc_name'] }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs3 layui-col-sm3 layui-row">
                            <select name="gt_id">
                                <option value=""></option>
                                @foreach($goods_type as $key => $value)
                                    <option value="{{ $value['gt_id'] }}">{{ $value['gt_name'] }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div>
                            <button class="layui-btn" lay-submit lay-filter="search_ok">查询</button>
                        </div>
                    </div>
                </form>
                <table id="goodsList" lay-filter="goodsList">
                    {{-- 商品图片 --}}
                    <script id="goodsImg" type="text/html">
                        @{{# if(d.goods_image !== null){ }}
                        <img src="@{{ d.goods_image }}" alt="" style="width: 50px;">
                        @{{# } }}
                    </script>
                    {{-- 价格 --}}
                    <script id="goodsPrice" type="text/html">
                        @{{ d.goods_price }}<span>/</span>@{{# if(d.goods_unit === null){ }} 个 @{{# }else{ }}@{{ d.goods_unit }}@{{# } }}
                    </script>
                    {{-- 是否推荐 --}}
                    <script id="isCommend" type="text/html">
                        @{{# if(d.goods_commend === 1){ }}是@{{# } }}
                        @{{# if(d.goods_commend === 0){ }}否@{{# } }}
                    </script>
                    {{-- 是否下架 --}}
                    <script id="state" type="text/html">
                        @{{# if(d.goods_state === 1){ }}正常@{{# } }}
                        @{{# if(d.goods_state === 0){ }}下架@{{# } }}
                    </script>
                    {{-- 操作 --}}
                    <script id="operation" type="text/html">
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" data-id="@{{ d.goods_id }}" lay-event="edit">修改</button>
                            @{{# if(d.goods_commend === 1){ }}
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" data-id="@{{ d.goods_id }}" lay-event="noCommend">取消推荐</button>
                            @{{# } }}
                            @{{# if(d.goods_commend === 0){ }}
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" data-id="@{{ d.goods_id }}" lay-event="commend">推荐</button>
                            @{{# } }}
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" data-id="@{{ d.goods_id }}" lay-event="del">删除</button>
                        </div>
                    </script>
                </table>
            </div>
            <div class="layui-tab-item">
                <form class="layui-form" action="">
                    <div class="layui-form-item layui-row">
                        <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs3 layui-col-sm3">
                            <input type="text" name="goods_name" required  lay-verify="required" placeholder="请输入菜品" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs3 layui-col-sm3 layui-row">
                            <select name="sgc_id">
                                <option value=""></option>
                                @foreach($class_list as $key => $value)
                                    <option value="{{ $value['sgc_id'] }}">{{ $value['sgc_name'] }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs3 layui-col-sm3 layui-row">
                            <select name="gt_id">
                                <option value=""></option>
                                @foreach($goods_type as $key => $value)
                                    <option value="{{ $value['gt_id'] }}">{{ $value['gt_name'] }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div>
                            <button class="layui-btn" lay-submit lay-filter="search_no">查询</button>
                        </div>
                    </div>
                </form>
                <table id="goodsListNo" lay-filter="goodsListNo">
                    {{-- 商品图片 --}}
                    <script id="goodsImg" type="text/html">
                        @{{# if(d.goods_image !== null){ }}
                        <img src="@{{ d.goods_image }}" alt="" style="width: 50px;">
                        @{{# } }}
                    </script>
                    {{-- 价格 --}}
                    <script id="goodsPrice" type="text/html">
                        @{{ d.goods_price }}<span>/</span>@{{# if(d.goods_unit === null){ }} 个 @{{# }else{ }}@{{ d.goods_unit }}@{{# } }}
                    </script>
                    {{-- 是否推荐 --}}
                    <script id="isCommend" type="text/html">
                        @{{# if(d.goods_commend === 1){ }}是@{{# } }}
                        @{{# if(d.goods_commend === 0){ }}否@{{# } }}
                    </script>
                    {{-- 是否下架 --}}
                    <script id="state" type="text/html">
                        @{{# if(d.goods_state === 1){ }}正常@{{# } }}
                        @{{# if(d.goods_state === 0){ }}下架@{{# } }}
                    </script>
                    {{-- 操作 --}}
                    <script id="operationDel" type="text/html">
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" data-id="@{{ d.goods_id }}" lay-event="del">正常</button>
                        </div>
                    </script>
                </table>
            </div>
        </div>
    </div>
    {{-- 添加菜品 --}}
    <div class="layui-fluid" id="addGoodsLayer" style="display: none;">
        <div class="layui-form">
            <form action="" class="layui-form">
                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="goods_name" required  lay-verify="required" placeholder="请输入菜品名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品类型</label>
                    <div class="layui-input-block">
                        <select name="gt_id" lay-verify="required">
                            <option value=""></option>
                            @foreach($goods_type as $key => $value)
                            <option value="{{ $value['gt_id'] }}">{{ $value['gt_name'] }}</option>
                                @endforeach
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品分类</label>
                    <div class="layui-input-block">
                        <select name="sgc_id" lay-verify="required">
                            <option value=""></option>
                            @foreach($class_list as $key => $value)
                                <option value="{{ $value['sgc_id'] }}">{{ $value['sgc_name'] }}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否推荐</label>
                    <div class="layui-input-block">
                        <input type="radio" name="goods_commend" value="1" title="是">
                        <input type="radio" name="goods_commend" value="0" title="否" checked>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品价格</label>
                    <div class="layui-input-block">
                        <input type="text" name="goods_price" required  lay-verify="required" placeholder="请输入菜品价格" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品单位</label>
                    <div class="layui-input-block">
                        <input type="text" name="goods_unit" required  lay-verify="required" placeholder="请输入菜品价格" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品图片</label>
                    <div class="layui-input-block">
                        <input type="hidden" name="goods_image" required  lay-verify="required" autocomplete="off" class="layui-input">
                        <button type="button" class="layui-btn" id="uploadGoodsImage">
                            <i class="layui-icon">&#xe67c;</i>上传菜品图片
                        </button>
                        <div>
                            <img src="" alt="" id="goods_image_img" width="50px">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="addGoods">添加</button>
                    </div>
                </div>
            </form>
        </div>
    </div>


    <div class="layui-fluid" id="editGoodsLayer" style="display: none;">
        <div class="layui-form">
            <form action="" class="layui-form" lay-filter="editGoods">
                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                <input type="hidden" name="id">
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="goods_name" required  lay-verify="required" placeholder="请输入菜品名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品类型</label>
                    <div class="layui-input-block">
                        <select name="gt_id" lay-verify="required">
                            <option value=""></option>
                            @foreach($goods_type as $key => $value)
                                <option value="{{ $value['gt_id'] }}">{{ $value['gt_name'] }}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品分类</label>
                    <div class="layui-input-block">
                        <select name="sgc_id" lay-verify="required">
                            <option value=""></option>
                            @foreach($class_list as $key => $value)
                                <option value="{{ $value['sgc_id'] }}">{{ $value['sgc_name'] }}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否推荐</label>
                    <div class="layui-input-block">
                        <input type="radio" name="goods_commend" value="1" title="是">
                        <input type="radio" name="goods_commend" value="0" title="否" checked>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品价格</label>
                    <div class="layui-input-block">
                        <input type="text" name="goods_price" required  lay-verify="required" placeholder="请输入菜品价格" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品单位</label>
                    <div class="layui-input-block">
                        <input type="text" name="goods_unit" required  lay-verify="required" placeholder="请输入菜品价格" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜品图片</label>
                    <div class="layui-input-block">
                        <input type="hidden" name="goods_image" required  lay-verify="required" autocomplete="off" class="layui-input">
                        <button type="button" class="layui-btn" id="uploadGoodsImage">
                            <i class="layui-icon">&#xe67c;</i>上传菜品图片
                        </button>
                        <div>
                            <img src="" alt="" id="edit_goods_image_img" width="50px">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="editGoods">修改</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

@endsection
